package com.mxf.code.controller;

import com.mxf.code.entity.User;
import com.mxf.code.entity.UserRole;
import com.mxf.code.entity.UserRoleKey;
import com.mxf.code.service.UserRoleService;
import com.mxf.code.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author : [mxf]
 * @version : [v1.0]
 * @className : UserController
 * @description : [描述说明该类的功能]
 * @createTime : [2022/9/10 22:40]
 * @updateUser : [mxf]
 * @updateTime : [2022/9/10 22:40]
 * @updateRemark : [描述说明本次修改内容]
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    @Autowired
    private UserRoleService userRoleService;


    @GetMapping("/{id}")
    public User getUser(@PathVariable("id")Long id){
        System.out.println(userService.getClass().getName());
        return userService.selectByPrimaryKey(id);
    }

    @GetMapping("/role/{id}")
    public UserRole getUserRole(@PathVariable("id")Long id){
        System.out.println(userRoleService.getClass().getName());
        return userRoleService.selectByPrimaryKey(new UserRoleKey(id,1L));
    }
}
